/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.factory;

import java.util.Set;
import ru.jSkyRoom.interfaces.major.Major;
import ru.rakev.producer.Producer;
import ru.jSkyRoom.interfaces.major.Enchantment;
import ru.jSkyRoom.interfaces.major.Keyword;
import ru.jSkyRoom.interfaces.additional.HasEnchantment;
import ru.jSkyRoom.interfaces.additional.HasKeywords;
import skyproc.FormID;

/**
 *
 * @author Rakev
 */
public class MajorProducerFactory {

    private static MajorProducerFactory instance = new MajorProducerFactory();

    public static MajorProducerFactory create() {
        return instance;
    }

    protected MajorProducerFactory() {
    }
    private static Producer<Major, String> edidProducer = new Producer<Major, String>() {
        @Override
        public String produce(Major fromObject) {
            return fromObject.getEDID();
        }
    };
    private static Producer<Major, FormID> formIdProducer = new Producer<Major, FormID>() {
        @Override
        public FormID produce(Major fromObject) {
            return fromObject.getForm();
        }
    };
    private static Producer<HasEnchantment, Enchantment> enchantmentProducer = new Producer<HasEnchantment, Enchantment>() {
        @Override
        public Enchantment produce(HasEnchantment fromObject) {
            return fromObject.getEnchantment();
        }
    };
    private static Producer<HasKeywords, Set<Keyword>> keywordsProducer = new Producer<HasKeywords, Set<Keyword>>() {
        @Override
        public Set<Keyword> produce(HasKeywords fromObject) {
            return fromObject.getKeywords();
        }
    };

    public <T extends Major> Producer<T, String> createEdidProducer() {
        return (Producer<T, String>) MajorProducerFactory.edidProducer;
    }

    public <T extends Major> Producer<T, FormID> createFormIdProducer() {
        return (Producer<T, FormID>) MajorProducerFactory.formIdProducer;
    }

    public <T extends HasEnchantment> Producer<T, Enchantment> createEnchantmentProducer() {
        return (Producer<T, Enchantment>) MajorProducerFactory.enchantmentProducer;
    }

    public <T extends HasKeywords> Producer<T, Set<Keyword>> createKeywordsProducer() {
        return (Producer<T, Set<Keyword>>) MajorProducerFactory.keywordsProducer;
    }
}
